package com.dbqn.zhao.service.impl;

import com.dbqn.zhao.entiy.User;
import com.dbqn.zhao.service.BaseService;

import java.util.List;
import java.util.Scanner;

public class DeleteImpl implements BaseService {

    Scanner sc=new Scanner(System.in);

    @Override
    public List excute(List list) {

        System.out.println("*****取消订单******");
        System.out.println("请输入您要取消的单号:");
        String danh=sc.next();

        User jies= panduna(danh,list);//判断单号是否存在

        if(jies==null){
                System.out.println("您输入的订单编号不正确！");
                return null;
            }else{
                    list.clear();
                    System.out.println("订单已取消！");
            System.out.println("***********");

                }




        return null;
    }


    public User panduna(String s,List list){

        for (int i = 0; i < list.size(); i++) {

            User user=(User)list.get(i);
            if( s.equals(user.getDanh())){
                return user;
            }

        }

        return null;

    }

}
